package kr.saeildamil.androidstudy.ch08;

import android.app.Activity;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Toast;

public class HandleEvent02 extends Activity {

	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		View mv = new View(this);
		setContentView(mv);
		mv.setOnTouchListener(listener);
	} // end of oncreate

	TouchListenerClass listener = new TouchListenerClass();
	
	class TouchListenerClass implements View.OnTouchListener {
		public boolean onTouch(View v, MotionEvent event) {
			float x = event.getX();
			float y = event.getY();
			if (event.getAction() == MotionEvent.ACTION_DOWN) { // 눌렀냐는 말임
				Toast.makeText(HandleEvent02.this,
						"Point " + x + ", " + y + "를  Action Down!",
						Toast.LENGTH_LONG).show();
				return true;
			} else if (event.getAction() == MotionEvent.ACTION_UP) {
				Toast.makeText(HandleEvent02.this, "Action Up!",
						Toast.LENGTH_LONG).show();
				return true;
			}

			return false;
		}

	}
}
